import mitt from 'mitt'

const emitter = {
	...mitt(),
	once(event, handler) {
		const wrapper = (...args) => {
			handler(...args) // 执行传入的 handler
			emitter.off(event, wrapper) // 事件触发后移除监听器
		}
		emitter.on(event, wrapper)
	}
}

export default emitter
